package src.ee.ioc.smaug.fsm;

/**
 * Class for describing state
 * 
 * @author Margarita Spichakova
 * 
 */
public class State {
    /**
     * State identificator
     */
    private int stateID;

    /**
     * Is given states reachable. (default value - false)
     */
    private boolean reachable = false;

    /**
     * State value - the output symbol
     */
    private char stateValue;

    /**
     * Is initial state?
     */
    private boolean initialState;

    /**
     * Is state final?
     */
    private boolean finalState;

    /**
     * Is state active?
     */
    private boolean active = true;

    /**
     * Constructor
     * 
     * @param stateID
     *            state identificator
     * @param stateValue
     *            value at the state
     * @param initialState
     *            is initial?
     * @param finalState
     *            is final?
     */
    public State(int stateID, char stateValue, boolean initialState,
            boolean finalState) {
        this.stateID = stateID;
        this.stateValue = stateValue;
        this.initialState = initialState;
        this.finalState = finalState;
        this.setActive(true);
        this.setReachable(true);
    }

   /**
     * Reacheble getter
     * 
     * @return reachable value
     */
    public boolean isReachable() {
        return reachable;
    }

    /**
     * Set reachable field
     * 
     * @param reachable
     *            is state reachable
     */
    public void setReachable(boolean reachable) {
        this.reachable = reachable;
    }

    /**
     * State id getter
     * 
     * @return state identificator
     */
    public int getStateID() {
        return stateID;
    }

    /**
     * State id setter
     * 
     * @param stateID
     */
    public void setStateID(int stateID) {
        this.stateID = stateID;
    }

    /**
     * State value getter
     * 
     * @return state value
     */
    public char getStateValue() {
        return stateValue;
    }

    /**
     * State value setter
     * 
     * @param stateValue
     *            output symbol stored in state
     */
    public void setStateValue(char stateValue) {
        this.stateValue = stateValue;
    }

    /**
     * InitialState getter
     * 
     * @return true if state is initial
     */
    public boolean isInitialState() {
        return initialState;
    }

    /**
     * InitialState setter
     * 
     * @param initialState
     *            true if state is initial othewise - false
     */
    public void setInitialState(boolean initialState) {
        this.initialState = initialState;
    }

    /**
     * Is state final
     * 
     * @return true if state is final
     */
    public boolean isFinalState() {
        return finalState;
    }

    /**
     * Set state final/not final
     * 
     * @param finalState
     *            true if state is final
     */
    public void setFinalState(boolean finalState) {
        this.finalState = finalState;
    }

    /**
     * 
     * @return true if state is active
     */
    public boolean isActive() {
        return active;
    }

    /**
     * Set state active or not
     * 
     * @param active
     *            true if state is active
     */
    public void setActive(boolean active) {
        this.active = active;
    }
    
    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    public String toString() {
        String s=new String();
        s="State: "+stateID+ "/"+ stateValue + " i?=" +initialState+ " f?="+finalState;
        return s;
    }
}
